<template>
	<view class="index-list">
		<view class="index-list-item index-list1">
			<view class="">
				<image :src="item.userpic" 
				mode="widthFix" 
				lazy-load></image>
				{{item.username}}
			</view>
			<view class="" v-show="!isguanzhu" @tap="guanzhu">
				<view class="icon iconfont icon-zengjia"></view>关注
			</view>
		</view>
		<view class="index-list-item index-list2" @tap="opendetail">
			我是标题
		</view>
		<view class="index-list-item index-list3" @tap="opendetail">
			<image :src="item.titlepic"
			mode="widthFix" 
			lazy-load></image>
			<template v-if="item.type=='video'">
				<view class="icon iconfont icon-bofang index-list-play"></view>
				<view class="index-list-playinfo">
					{{item.playnum}}次播放 {{item.long}}
				</view>
			</template>
		</view>
		<view class="index-list-item index-list4">
			<view class="u-f-ac">
				<view class="u-f-ac" @tap="caozuo('ding')" :class="{'active':infonum.index==1}">
					<view class="icon iconfont icon-icon_xiaolian-mian"></view>
					{{infonum.dingnum}}
				</view>
				<view class="u-f-ac" @tap="caozuo('cai')" :class="{'active':infonum.index==2}">
					<view class="icon iconfont icon-kulian"></view>
					{{infonum.cainum}}
				</view>
			</view>
			<view class="u-f-ac">
				<view class="u-f-ac">
					<view class="icon iconfont icon-pinglun1"></view>
					{{item.commentnum}}
				</view>
				<view class="u-f-ac">
					<view class="icon iconfont icon-zhuanfa"></view>
					{{item.sharenum}}
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	props:{
		item:Object,
		index:Number
	},
	data() {
		return {
			infonum: this.item.infonum,
			isguanzhu: this.item.isguanzhu,
		}
	},
	methods:{
		opendetail(){
			uni.navigateTo({
				url:'../../pages/detail/detail?detailData='+JSON.stringify(this.item),
			})
		},
		guanzhu(){
			this.isguanzhu=true
			uni.showToast({
				icon:'success',
				title:'关注成功'
			})
		},
		caozuo(type){
			switch(this.infonum.index){
				case 0:
					if(type=='ding'){
						this.infonum.dingnum++;
						this.infonum.index=1;
					}else{
						this.infonum.cainum++;
						this.infonum.index=2;
					}
				break;
				case 1:
					if(type=='ding')return;
					this.infonum.cainum++;
					this.infonum.dingnum--;
					this.infonum.index=2
				break;				
				default:
					if(type=='cai')return;
					this.infonum.dingnum++;
					this.infonum.cainum--;
					this.infonum.index=1;
				break;
			}
			// if(this.infonum.index==0){
			// 	if(type=='ding'){
			// 		this.infonum.dingnum++
			// 		this.infonum.index=1
			// 	}else{
			// 		this.infonum.cainum++
			// 		this.infonum.index=2
			// 	}
			// }else{
			// 	if(type=='ding'){
			// 		if(this.infonum.index==1)return
			// 		this.infonum.dingnum++
			// 		this.infonum.cainum--
			// 		this.infonum.index=1
			// 	}else{
			// 		if(this.infonum.index==2)return
			// 		this.infonum.dingnum--
			// 		this.infonum.cainum++
			// 		this.infonum.index=2
			// 	}
			// }

		}
	}
}
</script>

<style lang="less">
.index-list{
	padding: 20upx;
	border-bottom: 1upx solid #EEEEEE;
	margin-bottom: 40upx;
	.index-list-item{
		display: flex;
	}
	.index-list1 {
		display: flex;
		justify-content: space-between;
		>view:first-child{
			display: flex;
			align-items: center;
			line-height: 85upx;
			image {
				width: 85upx;
				height: 85upx;
				margin-right: 15upx;
				border-radius: 100%;				
			}
		}
		>view:last-child{
			display: flex;
			align-items: center;
		}
	}
	.index-list2{
		padding-top: 15upx;
		font-size: 32upx;
	}
	.index-list3{
		position: relative;
		display: flex;
		align-items: center;
		justify-content: center;
		image{
			width: 100%;
		}
		.index-list-play{
			position: absolute;
			color: #fff;
			font-size: 140upx;
		}
		.index-list-playinfo{
			position: absolute;
			bottom: 8upx;
			right: 8upx;
			background: rgba(51, 51, 51, 0.5);
			border-radius: 40upx;
			font-size: 22upx;
			padding: 0 12upx;
			
		}
	}
	.index-list4{
		display: flex;
		justify-content: space-between;
		margin-top: 10upx;
		.active{
			color: green;
		}
	}
}	
</style>
